<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta name="format-detection" content="telephone=no" />
    <title>代售和代购</title>
    <link rel="stylesheet" href="../../css/reset.css">
    <style>
        body {
            width: 100%;
            background-color: #f5f5f5;
            font-size: 0.28rem;
            height: auto;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            font-family: Helvetica;
            color: #333333;
        }

        .style_yes {
            color: #7dc371;
        }

        .style_yes2 {
            color: #ff8e3c;
        }

        .style_yes3 {
            color: #ddd;
        }

        .bigBox {
            position: relative;
            width: 100%;
            overflow: hidden;
        }

        .slidebox {
            position: relative;
            width: 200%;
            left: 0;
        }

        .slidebox>div {
            width: 50%;
            float: left;
        }
    </style>
</head>

<body>
    <div class="showlist" style="padding:0 0.25rem 0.25rem 0.25rem;margin-top: 0.15rem;background-color: #fff;">
        <div style="box-sizing:boeder-box;padding-bottom: 0.2rem;">
            <ul class="listdetail" id="ul_list">
            </ul>
            <div id="listState"
                style="text-align: center;margin: auto;color: #666666;margin-top: 10px;padding-top: 0.2rem;box-sizing: border-box;">

            </div>
        </div>
    </div>

    <script src="../../script/autosize.js"></script>
    <script src="../../script/fastclick.js"></script>
    <script src="../../script/dotmin.js"></script>
    <script src="../../script/jquery_three_two_one.js"></script>
    <script src="../../script/app.js"></script>
    <script>
        apiready = function () {
            var app = new APP();
            $("input").click(function () {
                $(this).focus().select(); //保险起见，还是加上这句。
            });
            var account = app.getAccount();
            var choose = "agentBuy"; //选择代购还是代售 agentBuy 代购 agentSell 代售
            var curPage = 1;
            var totalPage = 0;
            api.addEventListener(
                {
                    name: "bcnyList"
                }, function (ret) {
                    app.log("-------------------------------------" + JSON.stringify(ret));
                    if (ret && ret.value) {
                        choose = ret.value.chooseList;
                        $("#ul_list").empty();
                        curPage = 1;
                        totalPage = 0;
                        if (choose == "agentBuy") {
                            getbuylist(curPage, true);
                        } else {
                            getsellist(curPage, true);
                        }
                    }
                }
            );
            function getbuylist(curPage, isdown) {
                app.ajax({
                    param: {
                        method: "post",
                        url: app.ajaxUrl + "platform-coin-repurchase/bcny-change-lists",
                        data: {
                            values: {
                                token: account.token,
                                trade_type: "buy",
                                page: curPage
                            }
                        },
                        callback: function (ret, err) {
                            app.log("buy", "buycoinList返回：" + JSON.stringify(ret));
                            app.stopRefresh();
                            if (ret.code == 200) {
                                totalPage = ret.total_page;
                                var thisList = ret.data.data.lists;
                                thisList.map(function (item) {
                                    item.num = app.sliceNum(item.bcny_num, 2);
                                });
                                // 渲染模板
                                var temp = doT.template($("#buycoin").text());
                                if (isdown) {
                                    $("#ul_list").html(temp(thisList));
                                } else {
                                    $("#ul_list").append(temp(thisList));
                                }
                                if (curPage == 1 && thisList.length == 0) {
                                    $("#listState").text("暂时没有相关数据");
                                }
                            }
                        }
                    },
                    extra: {
                        container: "#ul_list",
                        isflower: false
                    }
                });
            }
            getbuylist(curPage, true);
            function getsellist(curPage, isdown) {
                app.ajax({
                    param: {
                        method: "post",
                        url: app.ajaxUrl + "platform-coin-repurchase/bcny-change-lists",
                        data: {
                            values: {
                                token: account.token,
                                trade_type: "sell",
                                page: curPage
                            }
                        },
                        callback: function (ret, err) {
                            app.log("获取列表返回：" + JSON.stringify(ret));
                            app.stopRefresh();
                            if (ret.code == 200) {
                                totalPage = ret.total_page;
                                var thisList = ret.data.data.lists;
                                // 渲染模板
                                var temp = doT.template($("#indentSellScuess").text());
                                if (isdown) {
                                    $("#ul_list").html(temp(thisList));
                                } else {
                                    $("#ul_list").append(temp(thisList));
                                }
                                if (curPage == 1 && thisList.length == 0) {
                                    $("#listState").text("暂时没有相关数据");
                                }
                            } else {
                                app.toast(ret.message);
                            }
                        }
                    },
                    extra: {
                        isflower: true,
                        delay: 200
                    }
                });
            }
            app.downRefresh(function () {
                curPage = 1;
                totalPage = 0;
                $("#ul_list").empty();
                if (choose == "agentBuy") {
                    getbuylist(curPage, true);
                } else {
                    getsellist(curPage, true);
                }
            });
            app.toBottom(function () {
                if (curPage < totalPage) {
                    curPage++;
                    if (choose == "agentBuy") {
                        getbuylist(curPage, false);
                    } else {
                        getsellist(curPage, false);
                    }
                }
            });
           app.headerMap();
        };
    </script>
    <script id="buycoin" type="text/html">
        {{~it:value:index}}
        <li
            style="display: inline-block;height: 1.6rem;width: 100%;border-bottom: 0.01rem solid #e1e1e1;display:flex;align-items: center;padding-top:0.15rem;">
            <div style="width: 100%;">
                <p
                    style="display: flex;display: -webkit-flex;justify-content: space-between;-webkit-justify-content: space-between;color: #181818;font-weight: 500;">
                    <span style="display: flex;display: -webkit-flex;color: #181818;align-items: center;">
                        <span
                            style="color:#7ed321;background-color:#e0f4d2;display: inline-block;height: 0.36rem;width:auto;font-size: 0.24rem;text-align: center;line-height: 0.36rem;border-radius: 0.05rem;padding:0.02rem 0.15rem;margin-right:0.1rem;">
                            兑入OTC余额
                        </span>
                        {{=value.trade_time}}
                    </span>
                    <span>
                        {{?value.currency_code=="cny"}}￥{{??value.currency_code=="usd"}}${{??value.currency_code=="eur"}}€
                        {{??value.currency_code=="hkd"}}HK${{??}}-{{?}}{{=value.legal_num}}
                    </span>
                </p>
                <p
                    style="display: flex;display: -webkit-flex;justify-content: space-between;-webkit-justify-content: space-between;color: #181818;font-size: 0.24rem;margin-top: 0.1rem;">
                    <span style="color: #adadad;">
                        <span style="margin-left: 0.12rem;">
                            兑入数量：{{=value.bcny_num}} OTC余额
                        </span>
                    </span>
                    <span style="color: #7ED321;">
                        {{?value.status==0}}
                        <span class="style_yes2">审核中</span>
                        {{??value.status==1}}
                        <span class="style_yes">成功</span>
                        {{??value.status==-1}}
                        <span class="style_yes3">失败</span>
                        {{?}}
                    </span>
                </p>
            </div>
        </li>
        {{~}}
    </script>
    <script id="indentSellScuess" type="text/html">
        {{~it:value:index}}
        <li
            style="display: inline-block;height: 1.6rem;width: 100%;border-bottom: 0.01rem solid #e1e1e1;display:flex;align-items: center;padding-top:0.15rem;">
            <div style="width: 100%;">
                <p
                    style="display: flex;display: -webkit-flex;justify-content: space-between;-webkit-justify-content: space-between;color: #181818;font-weight: 500;">
                    <span style="display: flex;display: -webkit-flex;color: #181818;align-items: center;">
                        <span
                            style="color:#ff6678;background-color:#ffe4e6;display: inline-block;height: 0.36rem;width:auto;font-size: 0.24rem;text-align: center;line-height: 0.36rem;border-radius: 0.05rem;padding:0.02rem 0.15rem;margin-right:0.1rem;">
                            兑出OTC余额
                        </span>
                        {{=value.trade_time}}
                    </span>
                    <span>
                        {{?value.currency_code=="cny"}}￥{{??value.currency_code=="usd"}}${{??value.currency_code=="eur"}}€
                        {{??value.currency_code=="hkd"}}HK${{??}}-{{?}}{{=value.legal_num}}
                    </span>
                </p>
                <p style="display: flex;display: -webkit-flex;justify-content: space-between;-webkit-justify-content: space-between;color: #181818;font-size: 0.24rem;margin-top: 0.1rem;">
                    <span style="color: #adadad;">
                        <span style="margin-left: 0.12rem;">
                            兑出数量：{{=value.bcny_num}} OTC余额
                        </span>
                    </span>
                    <span style="color: #adadad;">
                        成功
                    </span>
                </p>
            </div>
        </li>
        {{~}}
    </script>
</body>

</html>